# coding: utf-8
import sys

from qfluentwidgets import QConfig, Theme, qconfig, OptionsConfigItem, OptionsValidator, ColorConfigItem, ConfigItem

from .settings import CONFIG_DIR


def isWin11():
    return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000


class Config(QConfig):
    themeColor = ColorConfigItem("QFluentWidgets", "ThemeColor", '#0e64f4')
    dpiScale = OptionsConfigItem(
        "MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)

    # Http 请求相关配置
    cookie = ConfigItem("Http", "cookie", "")
    traceId = ConfigItem("Http", "traceId", "")
    # 登录相关配置
    username = ConfigItem("Login", "username", "")
    password = ConfigItem("Login", "password", "")
    phoneNumber = ConfigItem("Login", "phoneNumber", "")


cfg = Config()
cfg.themeMode.value = Theme.AUTO
qconfig.load(CONFIG_DIR / 'config.json', cfg)
